package com.dorado.example.service.impl;

import com.dorado.example.mapper.CompanyMapper;
import com.dorado.example.model.Company;
import com.dorado.example.model.CompanyExample;
import com.dorado.example.service.ICompanyService;
import com.dorado.example.service.IMongoService;
import com.dorado.example.service.IUserService;
import com.dorado.example.vo.AccessLog;
import com.dorado.example.vo.MongoLog;
import com.dorado.example.vo.UserVo;
import com.dorado.kernel.dao.service.impl.BaseServiceImpl;
import com.dorado.starter.mongodb.annotation.MongoDataSourceSwitch;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;


/**
 * jm_company
 * @author Debug
 */
@Slf4j
@Service("companyService")
public class CompanyServiceImpl extends BaseServiceImpl<Integer, Company, CompanyExample, CompanyMapper> implements ICompanyService {

    //@Autowired
    IMongoService mongoService;

    //@Autowired
    private IUserService userService;

    //@Autowired
    private MongoTemplate mongoTemplate;

    @MongoDataSourceSwitch(value = "config")
    @Override
    public void insert(AccessLog o) {
        UserVo vo = UserVo.builder().area("CompanyService->用户").build();
        userService.insert(vo);

        MongoLog dto = MongoLog.builder().area("昆山高").method("dfdfdfdfdfd").build();
        mongoService.insert(dto);

        mongoTemplate.insert(o);
    }
}